package com.lzx.indicatordemo.demo;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import com.framework.view.indicator.configs.GlobalConfig;
import com.framework.view.indicator.GodIndicator;
import com.framework.view.indicator.GodIndicatorAdapter;
import com.framework.view.indicator.indicators.configs.LineIndicatorConfig;
import com.framework.view.indicator.model.IndicatorShapeType;
import com.framework.view.indicator.model.IndicatorWidthModel;
import com.framework.view.indicator.configs.BadgeConfig;
import com.framework.view.indicator.configs.TextTitleConfig;
import com.lzx.indicatordemo.Constants;
import com.lzx.indicatordemo.ExamplePagerAdapter;
import com.lzx.indicatordemo.R;
import com.lzx.indicatordemo.ShowUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

import static com.lzx.indicatordemo.Constants.CHANNELS;
import static com.lzx.indicatordemo.Constants.normalTxtColor;
import static com.lzx.indicatordemo.Constants.normalTxtColors;
import static com.lzx.indicatordemo.Constants.selectedTxtColor;
import static com.lzx.indicatordemo.Constants.selectedTxtColors;

/**
 * description
 *
 * @author liangzx
 * @version 1.0
 * @time 2019-12-23 10:53
 **/
public class IndicatorWithBadgeDemoActivity extends AppCompatActivity {

    private List<String> mDataList = Arrays.asList(CHANNELS);
    private ViewPager mViewPager;
    private ExamplePagerAdapter mExamplePagerAdapter = new ExamplePagerAdapter(mDataList);
    private GodIndicatorAdapter mAdapter1, mAdapter2, mAdapter3, mAdapter4, mAdapter5, mAdapter6, mAdapter7, mAdapter8;

    private List<Integer> mBadgeNumbers = new ArrayList<>(mDataList.size());


    int t11 = BadgeConfig.BadgeAnchor.LEFT | BadgeConfig.BadgeAnchor.TOP;
    int t21 = BadgeConfig.BadgeAnchor.LEFT | BadgeConfig.BadgeAnchor.BOTTOM;
    int t31 = BadgeConfig.BadgeAnchor.LEFT | BadgeConfig.BadgeAnchor.CONTENT_TOP;
    int t41 = BadgeConfig.BadgeAnchor.LEFT | BadgeConfig.BadgeAnchor.CONTENT_BOTTOM;
    int t51 = BadgeConfig.BadgeAnchor.LEFT | BadgeConfig.BadgeAnchor.CENTER_Y;
    int t61 = BadgeConfig.BadgeAnchor.LEFT | BadgeConfig.BadgeAnchor.TOP_EDGE_CENTER_Y;
    int t71 = BadgeConfig.BadgeAnchor.LEFT | BadgeConfig.BadgeAnchor.BOTTOM_EDGE_CENTER_Y;

    int t12 = BadgeConfig.BadgeAnchor.RIGHT | BadgeConfig.BadgeAnchor.TOP;
    int t22 = BadgeConfig.BadgeAnchor.RIGHT | BadgeConfig.BadgeAnchor.BOTTOM;
    int t32 = BadgeConfig.BadgeAnchor.RIGHT | BadgeConfig.BadgeAnchor.CONTENT_TOP;
    int t42 = BadgeConfig.BadgeAnchor.RIGHT | BadgeConfig.BadgeAnchor.CONTENT_BOTTOM;
    int t52 = BadgeConfig.BadgeAnchor.RIGHT | BadgeConfig.BadgeAnchor.CENTER_Y;
    int t62 = BadgeConfig.BadgeAnchor.RIGHT | BadgeConfig.BadgeAnchor.TOP_EDGE_CENTER_Y;
    int t72 = BadgeConfig.BadgeAnchor.RIGHT | BadgeConfig.BadgeAnchor.BOTTOM_EDGE_CENTER_Y;

    int t13 = BadgeConfig.BadgeAnchor.CONTENT_LEFT | BadgeConfig.BadgeAnchor.TOP;
    int t23 = BadgeConfig.BadgeAnchor.CONTENT_LEFT | BadgeConfig.BadgeAnchor.BOTTOM;
    int t33 = BadgeConfig.BadgeAnchor.CONTENT_LEFT | BadgeConfig.BadgeAnchor.CONTENT_TOP;
    int t43 = BadgeConfig.BadgeAnchor.CONTENT_LEFT | BadgeConfig.BadgeAnchor.CONTENT_BOTTOM;
    int t53 = BadgeConfig.BadgeAnchor.CONTENT_LEFT | BadgeConfig.BadgeAnchor.CENTER_Y;
    int t63 = BadgeConfig.BadgeAnchor.CONTENT_LEFT | BadgeConfig.BadgeAnchor.TOP_EDGE_CENTER_Y;
    int t73 = BadgeConfig.BadgeAnchor.CONTENT_LEFT | BadgeConfig.BadgeAnchor.BOTTOM_EDGE_CENTER_Y;

    int t14 = BadgeConfig.BadgeAnchor.CONTENT_RIGHT | BadgeConfig.BadgeAnchor.TOP;
    int t24 = BadgeConfig.BadgeAnchor.CONTENT_RIGHT | BadgeConfig.BadgeAnchor.BOTTOM;
    int t34 = BadgeConfig.BadgeAnchor.CONTENT_RIGHT | BadgeConfig.BadgeAnchor.CONTENT_TOP;
    int t44 = BadgeConfig.BadgeAnchor.CONTENT_RIGHT | BadgeConfig.BadgeAnchor.CONTENT_BOTTOM;
    int t54 = BadgeConfig.BadgeAnchor.CONTENT_RIGHT | BadgeConfig.BadgeAnchor.CENTER_Y;
    int t64 = BadgeConfig.BadgeAnchor.CONTENT_RIGHT | BadgeConfig.BadgeAnchor.TOP_EDGE_CENTER_Y;
    int t74 = BadgeConfig.BadgeAnchor.CONTENT_RIGHT | BadgeConfig.BadgeAnchor.BOTTOM_EDGE_CENTER_Y;

    int t15 = BadgeConfig.BadgeAnchor.CENTER_X | BadgeConfig.BadgeAnchor.TOP;
    int t25 = BadgeConfig.BadgeAnchor.CENTER_X | BadgeConfig.BadgeAnchor.BOTTOM;
    int t35 = BadgeConfig.BadgeAnchor.CENTER_X | BadgeConfig.BadgeAnchor.CONTENT_TOP;
    int t45 = BadgeConfig.BadgeAnchor.CENTER_X | BadgeConfig.BadgeAnchor.CONTENT_BOTTOM;
    int t55 = BadgeConfig.BadgeAnchor.CENTER_X | BadgeConfig.BadgeAnchor.CENTER_Y;
    int t65 = BadgeConfig.BadgeAnchor.CENTER_X | BadgeConfig.BadgeAnchor.TOP_EDGE_CENTER_Y;
    int t75 = BadgeConfig.BadgeAnchor.CENTER_X | BadgeConfig.BadgeAnchor.BOTTOM_EDGE_CENTER_Y;

    int t16 = BadgeConfig.BadgeAnchor.LEFT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.TOP;
    int t26 = BadgeConfig.BadgeAnchor.LEFT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.BOTTOM;
    int t36 = BadgeConfig.BadgeAnchor.LEFT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.CONTENT_TOP;
    int t46 = BadgeConfig.BadgeAnchor.LEFT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.CONTENT_BOTTOM;
    int t56 = BadgeConfig.BadgeAnchor.LEFT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.CENTER_Y;
    int t66 = BadgeConfig.BadgeAnchor.LEFT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.TOP_EDGE_CENTER_Y;
    int t76 = BadgeConfig.BadgeAnchor.LEFT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.BOTTOM_EDGE_CENTER_Y;

    int t17 = BadgeConfig.BadgeAnchor.RIGHT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.TOP;
    int t27 = BadgeConfig.BadgeAnchor.RIGHT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.BOTTOM;
    int t37 = BadgeConfig.BadgeAnchor.RIGHT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.CONTENT_TOP;
    int t47 = BadgeConfig.BadgeAnchor.RIGHT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.CONTENT_BOTTOM;
    int t57 = BadgeConfig.BadgeAnchor.RIGHT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.CENTER_Y;
    int t67 = BadgeConfig.BadgeAnchor.RIGHT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.TOP_EDGE_CENTER_Y;
    int t77 = BadgeConfig.BadgeAnchor.RIGHT_EDGE_CENTER_X | BadgeConfig.BadgeAnchor.BOTTOM_EDGE_CENTER_Y;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.indicator_with_badge_demo_activity);

        mViewPager = findViewById(R.id.vp);
        mViewPager.setAdapter(mExamplePagerAdapter);
        randomBadgeNumbers();
        init1();
        init2();
        init3();
        init4();
        init5();
        init6();
        init7();
        init8();

        findViewById(R.id.all_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                randomBadgeNumbers();
                mAdapter1.notifyBadgeDataSetChanged();
                mAdapter2.notifyBadgeDataSetChanged();
                mAdapter3.notifyBadgeDataSetChanged();
                mAdapter4.notifyBadgeDataSetChanged();
                mAdapter5.notifyBadgeDataSetChanged();
                mAdapter6.notifyBadgeDataSetChanged();
                mAdapter7.notifyBadgeDataSetChanged();
                mAdapter8.notifyBadgeDataSetChanged();
            }
        });
        findViewById(R.id.one_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int position = new Random().nextInt(10);
                int number = new Random().nextInt(40) - 20;
                mAdapter1.notifyBadgeDataSetChanged(position, number);
                mAdapter2.notifyBadgeDataSetChanged(position, number);
                mAdapter3.notifyBadgeDataSetChanged(position, number);
                mAdapter4.notifyBadgeDataSetChanged(position, number);
                mAdapter5.notifyBadgeDataSetChanged(position, number);
                mAdapter6.notifyBadgeDataSetChanged(position, number);
                mAdapter7.notifyBadgeDataSetChanged(position, number);
                mAdapter8.notifyBadgeDataSetChanged(position, number);
                ShowUtils.show(IndicatorWithBadgeDemoActivity.this, (number > 0 ? "显示" : "隐藏") + "第" + (position + 1) + "个");
            }
        });
    }

    /**
     * 随机角标数字
     */
    private void randomBadgeNumbers() {
        mBadgeNumbers.clear();
        for (int i = 0; i < mDataList.size(); i++) {
            mBadgeNumbers.add(new Random().nextInt(120));
        }
    }

    private void init1() {
        GodIndicator godIndicator = findViewById(R.id.g1);
        godIndicator.setBackgroundColor(Constants.randomBgColor());
        godIndicator.setAdapter(mAdapter1 = new GodIndicatorAdapter<LineIndicatorConfig>(mViewPager) {
            @Override
            protected TextTitleConfig bindTitleConfig() {
                return TextTitleConfig.factory()
                        .setNormalColors(normalTxtColors)
                        .setSelectedColors(selectedTxtColors)
                        .setPendingLeft(20)
                        .setPendingRight(20)
                        .setNormalSize(30)
                        .setSelectedSize(40);
            }

            @Override
            public String getTitleName(int position) {
                return mDataList.get(position);
            }

            @Override
            public int getCount() {
                return mDataList.size();
            }

            @Override
            protected LineIndicatorConfig bindIndicatorConfig() {
                return LineIndicatorConfig.factory()
                        .setTop()
                        .setWidthModel(IndicatorWidthModel.MATCH_EDGE)
                        .setColors(Constants.indicatorColors)
                        .setShapeType(IndicatorShapeType.ROUND_RECT)
                        .setPendingLeft(10)
                        .setPendingTop(5)
                        .setRoundRadius(10)
                        .setPendingRight(10);
            }

            @Override
            public BadgeConfig bindBadgeConfig(int position) {
                BadgeConfig config = BadgeConfig.factory();
                config.setRadius(13)
                        .setTxtSize(20)
                        .setTxtPendingLR(5)
                        .setAutoStretch(true)
                        .setCornerRadius(13)
                        .setShowNumber(true);
                if (position == 0) {
                    config.setAnchor(t11);
                } else if (position == 1) {
                    config.setAnchor(t21);
                } else if (position == 2) {
                    config.setAnchor(t31);
                } else if (position == 3) {
                    config.setAnchor(t41);
                } else if (position == 4) {
                    config.setAnchor(t51);
                } else if (position == 5) {
                    config.setAnchor(t61);
                } else if (position == 6) {
                    config.setAnchor(t71);
                } else if (position == 7) {
                    config.setAnchor(t12);
                } else if (position == 8) {
                    config.setAnchor(t22);
                } else if (position == 9) {
                    config.setAnchor(t32);
                } else if (position == 10) {
                    config.setAnchor(t42);
                }
                return config;
            }

            @Override
            public int getBadgeNumber(int position) {
                return mBadgeNumbers.get(position);
            }
        });
    }

    private void init2() {
        GodIndicator godIndicator = findViewById(R.id.g2);
        godIndicator.setBackgroundColor(Constants.randomBgColor());
        godIndicator.setAdapter(mAdapter2 = new GodIndicatorAdapter<LineIndicatorConfig>(mViewPager) {
            @Override
            protected TextTitleConfig bindTitleConfig() {
                return TextTitleConfig.factory()
                        .setNormalColor(normalTxtColor)
                        .setSelectedColor(selectedTxtColor)
                        .setPendingLeft(20)
                        .setPendingRight(20)
                        .setNormalSize(30)
                        .setSelectedSize(40);
            }

            @Override
            public String getTitleName(int position) {
                return mDataList.get(position);
            }

            @Override
            public int getCount() {
                return mDataList.size();
            }

            @Override
            protected void bindGlobalConfig(GlobalConfig config) {
                config.setPercentAfterScroll(0.3f)
                        .setFollowFinger(false);
            }

            @Override
            protected LineIndicatorConfig bindIndicatorConfig() {
                return LineIndicatorConfig.factory()
                        .setRoundRadius(10)
                        .setWidthModel(IndicatorWidthModel.WARP_CONTENT)
                        .setColor(Constants.randomIndicatorColor())
                        .setPendingBottom(5)
                        .setPendingLeft(10)
                        .setPendingRight(10);
            }

            @Override
            public BadgeConfig bindBadgeConfig(int position) {
                BadgeConfig config = BadgeConfig.factory();
                config.setRadius(13)
                        .setTxtSize(20)
                        .setTxtPendingLR(8)
                        .setAutoStretch(true)
                        .setCornerRadius(13)
                        .setStroke(3, Color.WHITE)
                        .setShowNumber(true);
                if (position == 0) {
                    config.setAnchor(t52);
                } else if (position == 1) {
                    config.setAnchor(t62);
                } else if (position == 2) {
                    config.setAnchor(t72);
                } else if (position == 3) {
                    config.setAnchor(t13);
                } else if (position == 4) {
                    config.setAnchor(t23);
                } else if (position == 5) {
                    config.setAnchor(t33);
                } else if (position == 6) {
                    config.setAnchor(t43);
                } else if (position == 7) {
                    config.setAnchor(t53);
                } else if (position == 8) {
                    config.setAnchor(t63);
                } else if (position == 9) {
                    config.setAnchor(t73);
                } else if (position == 10) {
                    config.setAnchor(t14);
                }
                return config;
            }

            @Override
            public int getBadgeNumber(int position) {
                return mBadgeNumbers.get(position);
            }
        });
    }

    private void init3() {
        GodIndicator godIndicator = findViewById(R.id.g3);
        godIndicator.setBackgroundColor(Constants.randomBgColor());
        godIndicator.setAdapter(mAdapter3 = new GodIndicatorAdapter<LineIndicatorConfig>(mViewPager) {
            @Override
            protected TextTitleConfig bindTitleConfig() {
                return TextTitleConfig.factory()
                        .setNormalColor(normalTxtColor)
                        .setSelectedColor(selectedTxtColor)
                        .setPendingLeft(20)
                        .setPendingRight(20)
                        .setNormalSize(30)
                        .setSelectedSize(40);
            }

            @Override
            public String getTitleName(int position) {
                return mDataList.get(position);
            }

            @Override
            public int getCount() {
                return mDataList.size();
            }

            @Override
            protected LineIndicatorConfig bindIndicatorConfig() {
                return LineIndicatorConfig.factory()
                        .setRoundRadius(10)
//                        .setColorFollowSlideChange(true)
                        .setWidthModel(IndicatorWidthModel.SELF_DEFINE)
                        .setWidth(100)
                        .setColors(Constants.indicatorColors);
            }

            @Override
            public BadgeConfig bindBadgeConfig(int position) {
                BadgeConfig config = BadgeConfig.factory();
                config.setRadius(13)
                        .setTxtSize(20)
                        .setTxtPendingLR(5)
                        .setAutoStretch(false)
                        .setCornerRadius(13)
                        .setShowNumber(true);
                if (position == 0) {
                    config.setAnchor(t24);
                } else if (position == 1) {
                    config.setAnchor(t34);
                } else if (position == 2) {
                    config.setAnchor(t44);
                } else if (position == 3) {
                    config.setAnchor(t54);
                } else if (position == 4) {
                    config.setAnchor(t64);
                } else if (position == 5) {
                    config.setAnchor(t74);
                } else if (position == 6) {
                    config.setAnchor(t15);
                } else if (position == 7) {
                    config.setAnchor(t25);
                } else if (position == 8) {
                    config.setAnchor(t35);
                } else if (position == 9) {
                    config.setAnchor(t45);
                } else if (position == 10) {
                    config.setAnchor(t55);
                }
                return config;
            }

            @Override
            public int getBadgeNumber(int position) {
                return mBadgeNumbers.get(position);
            }
        });
    }

    private void init4() {
        GodIndicator godIndicator = findViewById(R.id.g4);
        godIndicator.setBackgroundColor(Constants.randomBgColor());
        godIndicator.setAdapter(mAdapter4 = new GodIndicatorAdapter<LineIndicatorConfig>(mViewPager) {
            @Override
            protected TextTitleConfig bindTitleConfig() {
                TextTitleConfig config = TextTitleConfig.factory()
                        .setNormalColor(normalTxtColor)
                        .setSelectedColor(selectedTxtColor)
                        .setPendingLeft(20)
                        .setPendingRight(20)
                        .setNormalSize(30)
                        .setSelectedSize(40);
                return config;
            }

            @Override
            public String getTitleName(int position) {
                return mDataList.get(position);
            }

            @Override
            public int getCount() {
                return mDataList.size();
            }

            @Override
            protected LineIndicatorConfig bindIndicatorConfig() {
                return LineIndicatorConfig.factory()
                        .setRoundRadius(10)
                        .setWidthModel(IndicatorWidthModel.WARP_CONTENT)
                        .setColor(Constants.randomIndicatorColor());
            }

            @Override
            public BadgeConfig bindBadgeConfig(int position) {
                BadgeConfig config = BadgeConfig.factory();
                config.setRadius(6)
                        .setShowNumber(false);
                if (position == 0) {
                    config.setAnchor(t65);
                } else if (position == 1) {
                    config.setAnchor(t75);
                } else if (position == 2) {
                    config.setAnchor(t16);
                } else if (position == 3) {
                    config.setAnchor(t26);
                } else if (position == 4) {
                    config.setAnchor(t36);
                } else if (position == 5) {
                    config.setAnchor(t46);
                } else if (position == 6) {
                    config.setAnchor(t56);
                } else if (position == 7) {
                    config.setAnchor(t66);
                } else if (position == 8) {
                    config.setAnchor(t76);
                } else if (position == 9) {
                    config.setAnchor(t17);
                } else if (position == 10) {
                    config.setAnchor(t27);
                }
                return config;
            }

            @Override
            public int getBadgeNumber(int position) {
                return mBadgeNumbers.get(position);
            }
        });
    }

    private void init5() {
        GodIndicator godIndicator = findViewById(R.id.g5);
        godIndicator.setBackgroundColor(Constants.randomBgColor());
        godIndicator.setAdapter(mAdapter5 = new GodIndicatorAdapter<LineIndicatorConfig>(mViewPager) {
            @Override
            protected TextTitleConfig bindTitleConfig() {
                TextTitleConfig config = TextTitleConfig.factory()
                        .setNormalColor(normalTxtColor)
                        .setSelectedColor(selectedTxtColor)
                        .setPendingLeft(20)
                        .setPendingRight(20)
                        .setNormalSize(30)
                        .setSelectedSize(40);
                return config;
            }

            @Override
            public String getTitleName(int position) {
                return mDataList.get(position);
            }

            @Override
            public int getCount() {
                return mDataList.size();
            }

            @Override
            protected LineIndicatorConfig bindIndicatorConfig() {
                return LineIndicatorConfig.factory()
                        .setShapeType(IndicatorShapeType.CIRCLE)
                        .setHeight(20)
                        .setPendingBottom(10)
                        .setColors(Constants.indicatorColors)
                        .setWidthModel(IndicatorWidthModel.SELF_DEFINE);
            }

            @Override
            public BadgeConfig bindBadgeConfig(int position) {
                BadgeConfig config = BadgeConfig.factory();
                config.setRadius(6)
                        .setStroke(3, Color.WHITE)
                        .setShowNumber(false);
                if (position == 0) {
                    config.setAnchor(t37);
                } else if (position == 1) {
                    config.setAnchor(t47);
                } else if (position == 2) {
                    config.setAnchor(t57);
                } else if (position == 3) {
                    config.setAnchor(t67);
                } else if (position == 4) {
                    config.setAnchor(t77);
                } else {
                    config.setAnchor(t34);
                }
                return config;
            }

            @Override
            public int getBadgeNumber(int position) {
                return mBadgeNumbers.get(position);
            }
        });
    }

    private void init6() {
        GodIndicator godIndicator = findViewById(R.id.g6);
        godIndicator.setBackgroundColor(Constants.randomBgColor());
        godIndicator.setAdapter(mAdapter6 = new GodIndicatorAdapter<LineIndicatorConfig>(mViewPager) {
            @Override
            protected TextTitleConfig bindTitleConfig() {
                TextTitleConfig config = TextTitleConfig.factory()
                        .setNormalColor(normalTxtColor)
                        .setSelectedColor(selectedTxtColor)
                        .setPendingLeft(20)
                        .setPendingRight(20)
                        .setNormalSize(30)
                        .setSelectedSize(40);
                return config;
            }

            @Override
            public String getTitleName(int position) {
                return mDataList.get(position);
            }

            @Override
            public int getCount() {
                return mDataList.size();
            }

            @Override
            protected LineIndicatorConfig bindIndicatorConfig() {
                return LineIndicatorConfig.factory()
                        .setHeight(10)
                        .setColors(Constants.indicatorColors)
                        .setShowSharpCorner(true)
                        .setSharpCornerHeight(10)
                        .setSharpCornerWidth(20);
            }

            @Override
            public BadgeConfig bindBadgeConfig(int position) {
                BadgeConfig config = BadgeConfig.factory();
                return config;
            }

            @Override
            public int getBadgeNumber(int position) {
                return mBadgeNumbers.get(position);
            }
        });
    }

    private void init7() {
        GodIndicator godIndicator = findViewById(R.id.g7);
        godIndicator.setBackgroundColor(Constants.randomBgColor());
        godIndicator.setAdapter(mAdapter7 = new GodIndicatorAdapter<LineIndicatorConfig>(mViewPager) {
            @Override
            protected TextTitleConfig bindTitleConfig() {
                TextTitleConfig config = TextTitleConfig.factory()
                        .setNormalColor(normalTxtColor)
                        .setSelectedColor(selectedTxtColor)
                        .setPendingLeft(20)
                        .setPendingRight(20)
                        .setNormalSize(30)
                        .setSelectedSize(40);
                return config;
            }

            @Override
            public String getTitleName(int position) {
                return mDataList.get(position);
            }

            @Override
            public int getCount() {
                return mDataList.size();
            }

            @Override
            protected LineIndicatorConfig bindIndicatorConfig() {
                return LineIndicatorConfig.factory()
                        .setTop()
                        .setShapeType(IndicatorShapeType.ROUND_RECT)
                        .setRoundRadius(10)
                        .setHeight(10)
                        .setColors(Constants.indicatorColors)
                        .setShowSharpCorner(true)
                        .setSharpCornerHeight(10)
                        .setSharpCornerWidth(20);
            }

            @Override
            public BadgeConfig bindBadgeConfig(int position) {
                BadgeConfig config = BadgeConfig.factory();
                config.setOffsetY(10);
                return config;
            }

            @Override
            public int getBadgeNumber(int position) {
                return mBadgeNumbers.get(position);
            }
        });
    }

    private void init8() {
        GodIndicator godIndicator = findViewById(R.id.g8);
        godIndicator.setBackgroundColor(Constants.randomBgColor());
        godIndicator.setAdapter(mAdapter8 = new GodIndicatorAdapter<LineIndicatorConfig>(mViewPager) {
            @Override
            protected TextTitleConfig bindTitleConfig() {
                TextTitleConfig config = TextTitleConfig.factory()
                        .setNormalColor(normalTxtColor)
                        .setSelectedColor(selectedTxtColor)
                        .setPendingLeft(20)
                        .setPendingRight(20)
                        .setNormalSize(30)
                        .setSelectedSize(40);
                return config;
            }

            @Override
            public String getTitleName(int position) {
                return mDataList.get(position);
            }

            @Override
            public int getCount() {
                return mDataList.size();
            }

            @Override
            protected LineIndicatorConfig bindIndicatorConfig() {
                return LineIndicatorConfig.factory()
                        .setShapeType(IndicatorShapeType.CIRCLE)
                        .setRadius(20)
                        .setUseBezierEffect(true)
                        .setWidthModel(IndicatorWidthModel.WARP_CONTENT)
                        .setColor(Constants.randomIndicatorColor());
            }

            @Override
            public BadgeConfig bindBadgeConfig(int position) {
                BadgeConfig config = BadgeConfig.factory();
                config.setOffsetX(10);
                return config;
            }

            @Override
            public int getBadgeNumber(int position) {
                return mBadgeNumbers.get(position);
            }
        });
    }
}
